/*
 * @Description: 岗位信息 - 接口
 * @Author: DHL
 * @Date: 2022-10-24 21:00:47
 * @LastEditors: DHL
 * @LastEditTime: 2022-10-30 09:09:37
 */

import { $get, $post, $put, $exportExcel } from '/@/utils/http'
import { ContentTypeEnum } from '/@/constant/http'
import {
  PostModel,
  PostParams,
  PostPageParams,
  PostPageResultModel,
  PostResultModel,
  PostListResultModel
} from './model/postModel'

/**
 * 分页查询
 */
export const apiPostSearch = (searchParams: PostPageParams) =>
  $get<PostPageResultModel>({
    url: '/twbPost/search',
    params: searchParams
  })

/**
 * 根据ID获取详情
 */
export const apiPostGetById = (id: string) =>
  $get<PostResultModel>({
    url: '/twbPost/getById',
    params: { id: id }
  })

/**
 * 保存信息
 */
export const apiPostSave = (saveParams: PostModel) =>
  $post<PostResultModel>({
    url: '/twbPost/save',
    contentType: ContentTypeEnum.json,
    params: saveParams
  })

/**
 * 更新信息
 */
export const apiPostUpdateById = (updateParams: PostModel) =>
  $put<PostResultModel>({
    url: '/twbPost/updateById',
    contentType: ContentTypeEnum.json,
    params: updateParams
  })

/**
 * 批量删除信息
 */
export const apiPostBatchDeleteByIds = (ids: string) =>
  $post<PostResultModel>({
    url: '/twbPost/batchDeleteByIds',
    params: { ids: ids }
  })

/**
 * 批量逻辑删除
 */
export const apiPostLogicBatchDeleteByIds = (ids: string) =>
  $post<PostResultModel>({
    url: '/twbPost/logicBatchDeleteByIds',
    params: { ids: ids }
  })

/**
 * 导出
 */
export const apiPostExport = (searchParams: PostParams, fileName: string) =>
  $exportExcel<PostResultModel>(
    {
      url: '/twbPost/exportExcel',
      params: searchParams
    },
    fileName
  )

/**
 * 查询岗位列表
 * @param searchParams
 * @returns
 */
export const apiPostSearchList = (searchParams: PostParams) =>
  $get<PostListResultModel>({
    url: '/twbPost/searchList',
    params: searchParams
  })
